package me.gavincook.moon.plugin.action;

import javax.swing.*;

import org.jetbrains.annotations.Nullable;

import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.ui.DialogWrapper;

import me.gavincook.moon.plugin.ui.JavaBeanConverterUI;

/**
 * JavaBeanConverterAction
 *
 * @author gavincook
 * @version $ID: JavaBeanConverterAction.java, v0.1 2018-04-25 17:40 gavincook Exp $$
 */
public class JavaBeanConverterAction extends AnAction {

    private JavaBeanConverterUI javaBeanConverterUI;

    @Override
    public void actionPerformed(AnActionEvent e) {
        javaBeanConverterUI = e.getProject().getComponent(JavaBeanConverterUI.class);
        javaBeanConverterUI.createClassChooserIfNecessary(e.getProject());
        DialogWrapper dialogWrapper = new DialogWrapper(null) {
            {
                init();
            }

            @Nullable
            @Override
            protected JComponent createCenterPanel() {
                return javaBeanConverterUI.getContainerPanel();
            }
        };
        dialogWrapper.setSize(800, 1200);
        dialogWrapper.setTitle("Java Bean转换器生成");
        dialogWrapper.setOKActionEnabled(false);
        dialogWrapper.show();
    }
}
